package com.winning.vsts.merge.service.service.impl;

import com.winning.vsts.merge.service.constant.BranchNameEnum;
import com.winning.vsts.merge.service.domain.VstsProject;
import com.winning.vsts.merge.service.domain.VstsUser;
import com.winning.vsts.merge.service.service.BasePullRequestService;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * test分支合并
 *
 * @author lps
 * @date 2022/10/6
 */
@Service
public class DevelopPullRequestServiceImpl extends BasePullRequestService {


    @Override
    public boolean isSupport(String targetBranch) {
        /*return targetBranch.equals(BranchNameEnum.DEVELOP.getValue())
            || targetBranch.startsWith(BranchNameEnum.DEVELOP.getValue());*/
        //所有分支都可以合并
        return true;
    }


    @Override
    protected boolean isDeleteSourceBranch() {
        return false;
    }


    @Override
    protected void autoApprove(RestTemplate restTemplate, VstsProject vstsProject, String pullRequestId) {
        // 项目管理或者架构师审批
        VstsUser vstsUser = vstsContext.vstsUser(vstsProject);
        String vstsId = vstsUser.getVstsId();
        vstsClient.autoApprove(restTemplate, vstsProject, pullRequestId, vstsId);
    }
}
